﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace JsonNetConsole
{
    static class Program
    {
        static void Main(string[] args)
        {
            ParseTest();
            JsonConvertTest();
        }

        static void ParseTest()
        {
            var jsonString = "{\"id\":1, \"name\":\"なまえ\", \"nicknames\":[\"にっく\",\"ねーむ\"]}";
            var obj = JObject.Parse(jsonString);

            var id = (int)obj["id"];
            var name = (string)obj["name"];
            var nickname1 = (string)obj["nicknames"][1];
        }

        static void JsonConvertTest()
        {
            var jsonString = JsonConvert.SerializeObject(new object[] { "abc", 123 });

            var objs1 = JsonConvert.DeserializeObject<object[]>(jsonString);
            var objs2 = (JArray)JsonConvert.DeserializeObject(jsonString);
        }
    }
}
